home *** CD-ROM | disk | FTP | other *** search
/ Trading on the Edge / Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin / pc / mac_file / vendor_d / neuralwa / nw2v50 / spr.inh < prev    next >
Text File  |  1993-08-23  |  7KB  |  277 lines

  1. inst4.1
  2. !****************************************************************
  3. !*                                *
  4. !*    Spatio-Temporal Pattern Recognition Network Generator    *
  5. !*                                *
  6. !****************************************************************
  7. ! Input:    # of input PE's
  8. ! Hidden 1:    if non-zero, add a normalizing layer (polar norm)
  9. ! Hidden 2:    # of temporal steps to generate network for (# of SPR layers)
  10. ! Output:    # of classes of output
  11. !
  12. ! register usage:
  13. !    n0 =  previous layer number
  14. !    n1 =  input layer (or normalizing layer)
  15. !    n2 =  "output" layer (where outputs go)        
  16. !    n3 =  result of global inhibition layer
  17. !    n4 =  current category number (PE in output)
  18. !    n5 =  counter of number of layers to add
  19.  
  20. !    *** check that input / hidden / output PE count is non-zero
  21.  
  22. ?&In    1
  23. >bge    CheckOut
  24. @Err    "SPR MUST have at least one input PE"
  25. :CheckOut
  26. ?&Out    1
  27. >bge    OutOK
  28. @Err    "SPR MUST have at least one output PE"
  29. :OutOK
  30. ?&Hd2    2
  31. >bge    HidOK
  32. @Err    "SPR MUST have at lease two temporal time steps (Hidden 2)"
  33. :HidOK
  34.  
  35. !    *** Load the Control Strategy and LRS if needed
  36.  
  37. @LdCS    "spr"            !control strategy
  38. @LdLR    "spr"            !L/R schedule
  39.  
  40. =netn    "InstaNet (tm) SPR (Avalanche) Network version 2.00 20-Sep-89"
  41. =DLnF    0            !learn  re-display off
  42. =DRcF    0            !recall re-display off
  43.  
  44. !    *** Build the Input Layer ***
  45.  
  46. @LLdf                !load default layer to mi_layer structure
  47. =LDln    "In"            !layer name
  48. =Lpes    &In            !copy # of input PEs from menu
  49. =x    100            !place to put layer on screen
  50. =y     80
  51. #Incl    "stdnwgtf.iif"        !standard # weight fields
  52. @LAdd                !add the input layer
  53. =n1    LayN            !input layer
  54. =n0    LayN            !prior layer
  55.  
  56. !    *** Add a layer to compute the Polar Norm (if Hidden 1 != 0) ***
  57.  
  58. ?&Hd1    0            !normalizing layer?
  59. >ble    NoNorm            !no
  60. @LLdf                !load default layer to mi_layer structure
  61. =LDln    "Norm"            !layer name
  62. =Lpes    &In            !set number of PEs
  63. +Lpes    1            !# of inputs + 1
  64. =Lsum    "NormPolar"        !special normalization
  65. +y    50
  66. #Incl    "stdnwgtf.iif"        !standard # weight fields
  67. @LAdd                !add the layer
  68. =n1    LayN            !use norm layer as "input" for now
  69.  
  70. =SPEl    LayN            !current layer
  71. @SlPE
  72. =NPEl    n0            !input layer
  73. @NrPE
  74. =cnwt    1.0            !unit weights
  75. =cnty    WFix            !fixed weights
  76. =cnsc    WRel            !relative positions
  77. @LCCr                !connect corresponding PEs
  78. =n0    LayN            !previous layer
  79. :NoNorm
  80.  
  81. !    *** Build as many SPR layers as required and connect them up ***
  82.  
  83. =n5    &Out            !number of SPR layers to build
  84.  
  85. :MkSPR                !*** Main loop to build SPR layers ***
  86. @LLdf                !start with default layer again
  87. =LDln    "SPR"            !layer name
  88. +LDln    LayN            !con-catenante layer number
  89. =Lpes    &Hd2            !number of time steps in each sequence
  90. =Lsum    "SPR"            !summation function
  91. =Ltrn    "SPR"            !transfer function
  92. =Lcmp    "SPR"            !SPR competition during learning
  93. =Llrn    "SPR"            !learning rule
  94. =Llow    0.0            !limit low output to zero
  95. =Lhgh    1.0            !limit high output to one
  96. +y    50            !up higher on display
  97. #Incl    "stdnwgtf.iif"        !standard # weight fields
  98. @LAdd
  99. -n5    1            !decrement number of layers left to add
  100. ?n5    0
  101. >bgt    MkSPR            !keep adding layers
  102. =n0    LayN            !prior layer
  103.  
  104. !    *** Build the output layer & connect it to prior layer ***
  105.  
  106. @LLdf                !load default layer to mi_layer structure
  107. =LDln    "N Act"            !layer name
  108. =Lpes    &Out            !copy # of input PEs from menu
  109. =Llow    0.0            !minimum value of zero output
  110. +y    50
  111. #Incl    "stdnwgtf.iif"        !standard # weight fields
  112. @LAdd                !add the output layer
  113. =n2    LayN            !category layer to connect to
  114. =n0    LayN
  115.  
  116. @LLdf                !special sum layer
  117. =LDln    "NT"            !activity level in network
  118. =Lpes    1            !one PE
  119. +y    40
  120. -x    50
  121. #Incl    "stdnwgtf.iif"        !standard # weight fields
  122. @LAdd                !add it
  123.  
  124. =SPEn    0            !select PE number in layer
  125. =SPEl    LayN            !current layer
  126. @SlPE                !selecte it
  127. @LdSP
  128. =PENm    "Act"
  129. @SvSP
  130. =NPEn    0            !neare PE number in layer
  131. =NPEl    n0            !prior layer
  132. @NrPE                !point to it
  133.  
  134. =cnwt    1.0            !connection weight
  135. =cnty    WFix            !fixed weights
  136. =cnsc    WAbs            !absolute geometry
  137. @LCFl                !connect fully
  138.  
  139. =cnwt    0.0            !target activity level = # of steps in seq
  140. -cnwt    &Hd2
  141. =NPEl    -1            !bias layer
  142. @NrPE                !now we are near that PE
  143. @PCon                !connect it up
  144. =n0    LayN            !prior layer
  145.  
  146. !    *** build the multiply layer next ***
  147.  
  148. @LLdf                !load default layer to mi_layer structure
  149. =LDln    "I"            !layer name
  150. =Lpes    1            !only one PE in this layer
  151. =Llow    0            !minimum output of zero
  152. =Lhgh    2            !maximum output of one
  153. =Lsum    "CumSum"        !cumulative sum
  154. +y    40
  155. #Incl    "stdnwgtf.iif"        !standard # weight fields
  156. @LAdd                !add the inhibition layer
  157. =n3    LayN            !keep track of it for posterity
  158.  
  159. =NPEl    n0            !point to prior layer
  160. @NrPE
  161. =SPEl    LayN            !current layer
  162. @SlPE
  163. @LdSP
  164. =PENm    "Inh"
  165. @SvSP
  166. =cnwt    .05            !Inhibition must change slowly
  167. @PCon                !connect it to inhibitory term
  168.  
  169. =n0    LayN            !prior layer hook up
  170.  
  171. !    *** Create the network output layer ***
  172.  
  173. @LLdf                !special sum layer
  174. =LDln    "Out"            !output of the network network
  175. =Lpes    &Out            !total number of output PEs
  176. +y    40
  177. +x    50
  178. #Incl    "stdnwgtf.iif"        !standard # weight fields
  179. @LAdd                !add it
  180.  
  181. =SPEl    LayN            !select output layer
  182. @SlPE
  183. =NPEl    n2            !"prior" output layer
  184. @NrPE
  185. =cnwt    1.0
  186. /cnwt    &Hd2            !divide by # of inputs
  187. =cnsc    WRel
  188. @LCCr                !connect corresponding
  189.  
  190. !    *** go back and properly connect up the various SPR chains ***
  191. !        First, connect them to the output layer
  192.  
  193. =SPEl    n2            !output layer
  194. =NPEl    n1            !"input" layer
  195. =cnwt    1.0            !connect to it with fixed weights
  196. =cnsc    WRel
  197. =cnty    WFix
  198. =n4    0            !start with category zero
  199. :CnOuts
  200. =SPEn    n4            !output PE to connect to
  201. @SlPE                !select the appropriate output PE
  202. +NPEl    1
  203. =NPEn    0            !start with PE 1 from current layer
  204. :Cn1O
  205. @NrPE                !selecte it
  206. @PCon                !connect it
  207. +NPEn    1            !next PE in layer
  208. ?NPEn    &Hd2            !are we done?
  209. >blt    Cn1O            !no, keep going
  210.  
  211. +n4    1            !next output category
  212. ?n4    &Out
  213. >blt    CnOuts
  214.  
  215. !    *** Go back through the SPR layer & connect up its inputs ***
  216.  
  217. =SPEl    n1            !point to input layer
  218. +SPEl    1            !next layer
  219. :CnSPR                !connect up SPR layer
  220. =NPEn    0            !near PE 0
  221. =NPEl    SPEl            !connect up chain first
  222. =SPEn    1
  223. @NrPE
  224. @SlPE
  225. =cnty    WSet            !modified weight
  226. =cnsc    WRel            !  connected relatively
  227. =cnwt    1.0            !  1.0
  228. @PCon                !connect it
  229. =NPEn    1            !both near & selected
  230. @NrPE
  231. @LCLk                !connect like
  232.  
  233. =cnsc    WAbs            !absolute connection to inhibition
  234. =cnty    WFix            !fixed weights too
  235. =cnwt    -1.0            !negative weight to inhibition
  236. =NPEn    0
  237. =NPEl    n3            !point to global inhibition
  238. @NrPE
  239. @LCFl                !connect fully to it
  240.  
  241. =cnty    WVar            !variable weights for input
  242. =cnwt    0.0            !zero for now (randomized later)
  243. =NPEl    n1            !point to input layer
  244. @NrPE
  245. @LCFl                !connect fully to it too
  246.  
  247. +SPEl    1            !next layer
  248. ?SPEl    n2            !are we done?
  249. >blt    CnSPR            !no, keep connecting
  250.  
  251.  
  252. !    *** Select Control Strategy & L/R Schedule ***
  253.  
  254. @LLsl                !load super layer
  255. =Lctl    "spr"            !SPR control strategy
  256. =Llrs    "spr"            !SPR L/R Schedule
  257. =Llnn    "spr"            !name of learn input
  258. =Lrcn    "spr"            !name of recall output
  259. =Lscl    -1            !input  low-value
  260. =Loff     1            !input  high-value
  261. =Lax1    Epch            !epoch size
  262. =Llow     0            !output low-value
  263. =Lhgh     1            !output high-value
  264. @SVsl                !save it back
  265. !
  266. !=Grph     1            !Activate instrument list
  267. !=GrLF    "spr"            !instrument list file
  268. !
  269. =jogl    -.1            !lower limit for jog
  270. =jogh    +.1            !upper limit for jog
  271. =seed    257            !starting seed number
  272. @seed                !set the seed
  273. @Nrnd                !randomize the network
  274.  
  275. @EOF
  276.  
  277.